<template>
  <div class="charts" ref="charts"></div>
</template>

<script>
import * as echarts from "echarts";
export default {
  data() {
    return {
      lineCharts: "",
    };
  },
  mounted() {
    //初始化echarts实例
    this.lineCharts = echarts.init(this.$refs.charts);
    this.lineCharts.setOption({
      xAxis: { show: false, type: "category" },
      yAxis: { show: false },
      series: [
        {
          data: [],
          type: "line",
          smooth: true,
          itemStyle: { opacity: 0 },
          lineStyle: { color: "pink" },
          areaStyle: {
            color: {
              type: "linear",
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              colorStops: [
                {
                  offset: 0,
                  color: "pink", // 0% 处的颜色
                },
                {
                  offset: 1,
                  color: "#fff", // 100% 处的颜色
                },
              ],
              global: false, // 缺省为 false
            },
          },
        },
      ],
      grid: {
        left: 0,
        top: 0,
        right: 0,
        bottom: 0,
      },
    });
  },
  computed: {
    visitTrend() {
      //日访问趋势图数据
      return this.$store.state.home.list.visitTrend;
    },
  },
  watch: {
    visitTrend() {
      this.lineCharts.setOption({
        series: [{ data: this.visitTrend }],
      });
    },
  },
};
</script>

<style lang="css" scoped>
.charts {
  width: 100%;
  height: 100%;
}
</style>
